<template>
	<view>
		<view class="down">
			<view :class="indexnav==0?'active':''" @click="indexkndex(0)">已签收</view>
			<view :class="indexnav==1?'active':''" @click="indexkndex(1)">未签收</view>
		</view>
		<view v-if="indexnav == 0">
			<view class="success" @click="detailed(item)" v-for="(item,index) in list">
				<view class="success_key">
					<view class="viewtop">
						<text>{{item.tWaybill.shipZone}}</text>
						<image src="../../static/iocn4.png"></image>
						<text>{{item.tWaybill.receiveZone}}</text>
					</view>
					<view class="viewbox">
						<text>货物信息：{{item.tWaybill.goodsName}} / {{item.tWaybill.goodsWeight}}T / {{item.tWaybill.goodsSize}}m³ / {{item.tWaybill.goodsPackagMethod}}</text>
						<text>车辆信息：{{item.tWaybill.lesscarload}} / {{item.tWaybill.demandLoad}}T / {{item.tWaybill.demandLength}}米 / {{item.tWaybill.demandStyle}} </text>
					</view>
				</view>
				<view class="success_box">
					<view>回单状态:{{item.status}}</view>
				</view>
			</view>
			<view v-if="list == 0">
				<u-empty mode="history" icon="http://cdn.uviewui.com/uview/empty/history.png"></u-empty>
			</view>
		</view>
		<view v-if="indexnav == 1">
			<view class="success" v-for="(item,index) in lista">
				<view class="success_key">
					<view class="viewtop">
						<text>{{item.tWaybill.shipZone}}</text>
						<image src="../../static/iocn4.png"></image>
						<text>{{item.tWaybill.receiveZone}}</text>
					</view>
					<view class="viewbox">
						<text>货物信息：{{item.tWaybill.goodsName}} / {{item.tWaybill.goodsWeight}}T / {{item.tWaybill.goodsSize}}m³ / {{item.tWaybill.goodsPackagMethod}}</text>
						<text>车辆信息：{{item.tWaybill.lesscarload}} / {{item.tWaybill.demandLoad}}T / {{item.tWaybill.demandLength}}米 / {{item.tWaybill.demandStyle}} </text>
					</view>
				</view>
				<view class="sucss_box">
					<view :class="navstatus==1?'active':''" @click="navstatuskndex(1)">
						<image src="../../static/iocn25.png" v-if="navstatus == 1"></image>
						<image src="../../static/iocn26.png" v-else></image>
						<text>发出回单</text>
					</view>
					<view :class="navstatus==2?'active':''" @click="navstatuskndex(2)">
						<image src="../../static/iocn25.png" v-if="navstatus == 2"></image>
						<image src="../../static/iocn26.png" v-else></image>
						<text>客户签收</text>
					</view>
					<view :class="navstatus==3?'active':''" @click="navstatuskndex(3)">
						<image src="../../static/iocn25.png" v-if="navstatus == 3"></image>
						<image src="../../static/iocn26.png" v-else></image>
						<text>异常终止</text>
					</view>
				</view>
				<view class="success_list">
					<view @click="UStatus(item)">确认签收</view>
				</view>
			</view>
			<view v-if="lista == 0">
				<u-empty mode="history" icon="http://cdn.uviewui.com/uview/empty/history.png"></u-empty>
			</view>
		</view>
	</view>
</template>

<script>
	import {GetReceiptBills,UptReceiptBillStatus} from '@/public/Api/update.js'
	import {
		setValue,
		getValue
	} from '@/public/storeage/index.js'
	export default {
		data() {
			return {
				skipCount:0,
				maxResultCount:10,
				list:[],
				lista:[],
				indexnav:0,
				navstatus:0
			};
		},
		onLoad() {
			this.yiqianshou()
			this.weiqianshou()
		},
		
		methods:{
			indexkndex(e){
				this.indexnav = e
			},
			// 回单管理 -- 已签收
			async yiqianshou() {
				var skipCount = this.skipCount
				var maxResultCount = this.maxResultCount
				var userId=getValue('id')
				try {
					const {
						data: res
					} = await GetReceiptBills({
						skipCount,
						maxResultCount,
						userId,
						isReceipt:1
					})
					this.list = res.result.items
				} catch (e) {}
			},
			
			// 回单管理 -- 未签收
			async weiqianshou() {
				var skipCount = this.skipCount
				var maxResultCount = this.maxResultCount
				var userId=getValue('id')
				try {
					const {
						data: res
					} = await GetReceiptBills({
						skipCount,
						maxResultCount,
						userId,
						isReceipt:0
					})
					this.lista = res.result.items
				} catch (e) {}
			},
			
			navstatuskndex(e){
				this.navstatus = e
			},
			
			
			async UStatus(e) {
				var status = this.navstatus
				var id = e.id
				console.log(status,id)
				if (status == '0') {
					uni.showToast({
						title: "状态不能为空",
						icon: 'none',
						duration: 2000
					})
					return false
				}
				try {
					const {
						data: res
					} = await UptReceiptBillStatus({
						status,
						id
					})
				} catch (e) {}
			},
			
		}
	}
</script>

<style lang="scss">
	page{
		background-color: #f7f7f7;
		padding: 0 15upx;
	}
	.down {
		width: 250upx;
		height: 63upx;
		border-radius: 17upx;
		overflow: hidden;
		box-shadow: 1.75px 1.75px 7.01px 0px rgba(0, 0, 0, 0.25), 1.75px 1.75px 7.01px 0px rgba(0, 0, 0, 0.25);
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-top: 20upx;
	
		view {
			width: 50%;
			font-size: 28upx;
			font-weight: bold;
			text-align: center;
			border-radius: 17upx;
			height: 63upx;
			line-height: 63upx;
		}
	
		.active {
			background-color: #EF4D3D;
			color: #fff;
		}
	}
	
	.success {
		width: 100%;
		background-color: #fff;
		padding: 25upx;
		box-shadow: 1.75upx 1.75upx 7.01upx 0px #e5e5e5, 1.75upx 1.75upx 7.01upx 0px #e5e5e5;
		margin-top: 20upx;
		border-radius: 20upx;
		position: relative;
	
		.success_key {
			margin-top: -30upx;
			border-bottom: 2upx solid #E5E5E5;
			padding-bottom: 30upx;
			.viewtop {
				display: flex;
				align-items: center;
	
				text {
					font-size: 28upx;
					color: #000;
					font-weight: bold;
				}
	
				image {
					width: 96upx;
					height: 96upx;
				}
			}
	
			.viewbox {
				margin-top: -30upx;
	
				text {
					display: block;
					font-size: 21upx;
					color: #383838;
					padding-top: 10upx;
				}
			}
		}
	
		.success_box{
			padding-top: 20upx;
			view{
				font-size: 26upx;
				color: #EF4D3D;
			}
		}
		
		.sucss_box{
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 20upx 0;
			border-bottom: 2upx solid #E5E5E5;
			view{
				display: flex;
				align-items: center;
				image{
					width: 16upx;
					height: 16upx;
				}
				text{
					font-size: 25upx;
					padding-left: 10upx;
				}
			}
		}
		
		.success_list{
			display: flex;
			align-items: center;
			justify-content: flex-end;
			padding-top: 25upx;
			view{
				width: 189upx;
				height: 72upx;
				text-align: center;
				line-height: 72upx;
				background-color: #EF4D3D;
				border-radius: 15upx;
				color: #fff;
				font-size: 31upx;
				font-weight: bold;
			}
		}

	}
</style>
